package com.ledtechdesign.beans.api.xml;

import java.util.List;

import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;

import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

import com.ledtechdesign.beans.api.ElementDelegate;
import com.ledtechdesign.beans.api.INode;
import com.ledtechdesign.beans.api.IRepository;

public class RepositoryXML extends ElementDelegate<Element> implements
		IRepository {
	NodeList nodes;
	XPath xpath;
	public final String XPATH_STRING = "/repository";

	public RepositoryXML(Element ee) {
		super(ee);
		xpath= XPathFactory.newInstance().newXPath();
	}

	public List<INode> getChildren() {
		// TODO 
		return null;
	}

	public int getChildrenCount() {
		// TODO 
		return 0;
	}

	public String getHref() {
		// TODO 
		return null;
	}

	public INode getTopNode() {
		// TODO 
		return null;
	}

	public int getTotalChildren() {

		try {
			Integer count = (Integer) this.xpath.evaluate("/children[count]",
					this.e, XPathConstants.NUMBER);
			return count;
		} catch (XPathExpressionException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return 0;
		}

	}

}
